home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / grafica / pvrgjpeg / globals.h < prev    next >
C/C++ Source or Header  |  1999-01-01  |  7KB  |  181 lines

  1. /*************************************************************
  2. Copyright (C) 1990, 1991, 1993 Andy C. Hung, all rights reserved.
  3. PUBLIC DOMAIN LICENSE: Stanford University Portable Video Research
  4. Group. If you use this software, you agree to the following: This
  5. program package is purely experimental, and is licensed "as is".
  6. Permission is granted to use, modify, and distribute this program
  7. without charge for any purpose, provided this license/ disclaimer
  8. notice appears in the copies.  No warranty or maintenance is given,
  9. either expressed or implied.  In no event shall the author(s) be
  10. liable to you or a third party for any special, incidental,
  11. consequential, or other damages, arising out of the use or inability
  12. to use the program for any purpose (or the loss of data), even if we
  13. have been advised of such possibilities.  Any public reference or
  14. advertisement of this source code should refer to it as the Portable
  15. Video Research Group (PVRG) code, and not by any author(s) (or
  16. Stanford University) name.
  17. *************************************************************/
  18. /*
  19. ************************************************************
  20. globals.h
  21.  
  22. This file contains the global includes and other definitions.
  23.  
  24. ************************************************************
  25. */
  26.  
  27. #ifndef GLOBAL_DONE
  28. #define GLOBAL_DONE
  29.  
  30. #include <stdio.h>
  31. #include "prototypes.h"
  32. #include "param.h"
  33. #include "system.h"
  34.  
  35.  
  36. /* Map stream functions to those used in stream.c (MSB) */
  37. /* Makes for easy alterations for least-significant bit non-JPEG defns. */
  38.  
  39. #define sropen mropen
  40. #define srclose mrclose
  41. #define swopen mwopen
  42. #define swclose mwclose
  43.  
  44. #define sgetb megetb
  45. #define sgetv megetv
  46. #define sputv meputv
  47.  
  48. #define swtell mwtell
  49. #define srtell mrtell
  50.  
  51. #define swseek mwseek
  52. #define srseek mrseek
  53.  
  54. #define IMAGE struct Image_Definition
  55. #define FRAME struct Frame_Definition
  56. #define SCAN struct Scan_Definition
  57.  
  58. #define MUTE 0
  59. #define WHISPER 1
  60. #define TALK 2
  61. #define NOISY 3
  62. #define SCREAM 4
  63.  
  64.  
  65. /* The defined flag for encoding/decoding. */
  66. #define J_DECODER 1
  67. #define J_FULLHUFFMAN 2
  68. #define J_DEFAULTHUFFMAN 4
  69. #define J_LOSSLESS 8
  70.  
  71. /* Some flags for JpegCustomScan() */
  72.  
  73. #define CUSTOM_DO_DC 1
  74. #define CUSTOM_DO_AC 2
  75.  
  76. /* Error flags */
  77.  
  78. #define ERROR_NONE 0
  79. #define ERROR_BOUNDS 1            /*Input Values out of bounds */
  80. #define ERROR_HUFFMAN_READ 2      /*Huffman Decoder finds bad code */
  81. #define ERROR_HUFFMAN_ENCODE 3    /*Undefined value in encoder */
  82. #define ERROR_MARKER 4            /*Error Found in Marker */
  83. #define ERROR_INIT_FILE 5         /*Cannot initialize files */
  84. #define ERROR_UNRECOVERABLE 6     /*No recovery mode specified */
  85. #define ERROR_PREMATURE_EOF 7     /*End of file unexpected */
  86. #define ERROR_MARKER_STRUCTURE 8  /*Bad Marker Structure */
  87. #define ERROR_WRITE 9             /*Cannot write output */
  88. #define ERROR_READ 10             /*Cannot write input */
  89. #define ERROR_PARAMETER 11        /*System Parameter Error */
  90. #define ERROR_MEMORY 12           /*Memory exceeded */
  91.  
  92. typedef int iFunc();
  93. typedef void vFunc();
  94.  
  95. /* A flag obtaining macro */
  96. #define GetFlag(value,flag) (((value) & (flag)) ? 1:0)
  97.  
  98. /* MAX and MIN macros */
  99. #define MAX(x,y) ((x > y) ? x:y)
  100. #define MIN(x,y) ((x > y) ? y:x)
  101.  
  102. /* BEGIN is used to start most routines. It sets up the Routine Name */
  103. /* which is used in the WHEREAMI() macro */
  104. #define BEGIN(name) static char RoutineName[]= name
  105. /* WHEREAMI prints out current location in code. */
  106. #define WHEREAMI() printf("F>%s:R>%s:L>%d: ",\
  107.               __FILE__,RoutineName,__LINE__)
  108.  
  109. /* InBounds is used to test whether a value is in or out of bounds. */
  110. #define InBounds(var,lo,hi,str)\
  111. {if (((var) < (lo)) || ((var) > (hi)))\
  112. {WHEREAMI(); printf("%s in %d\n",(str),(var));ErrorValue=ERROR_BOUNDS;}}
  113.  
  114. /* MakeStructure makes the named structure */
  115. #define MakeStructure(named_st) ((named_st *) malloc(sizeof(named_st)))
  116.  
  117. IMAGE {
  118. char *StreamFileName;            /* Name of compressed stream file */
  119. int JpegMode;                    /* Mode of JPEG encoder */
  120. int Jfif;                        /* If set, automatically drop JFIF marker */
  121. int ImageSequence;               /* Index in image sequence */
  122. int NumberQuantizationMatrices;  /* Number of quantization matrices */
  123. int *QuantizationMatrices[MAXIMUM_DEVICES]; /* Pointers to q-matrices */
  124. int NumberACTables;              /* Number of AC Huffman tables */
  125. DHUFF *ACDhuff[MAXIMUM_DEVICES]; /* Decoder huffman tables */
  126. EHUFF *ACEhuff[MAXIMUM_DEVICES]; /* Encoder huffman tables */
  127. XHUFF *ACXhuff[MAXIMUM_DEVICES]; /* Transmittable huffman tables */
  128. int NumberDCTables;              /* Number of DC Huffman tables */
  129. DHUFF *DCDhuff[MAXIMUM_DEVICES]; /* Decoder huffman tables */
  130. EHUFF *DCEhuff[MAXIMUM_DEVICES]; /* Encoder huffman tables */
  131. XHUFF *DCXhuff[MAXIMUM_DEVICES]; /* Transmittable huffman tables */
  132. };
  133.  
  134. FRAME {
  135. int Type;                       /* SOF(X) where X is type (4 bits) */
  136. char *ComponentFileName[MAXIMUM_COMPONENTS]; /* image component file names */
  137. int InsertDnl;                  /* DNL flag (-2 = AUTO) (-1 = ENABLE) (>0 ) */
  138. int Q;                          /* Q Factor (0 disables) */
  139. int DataPrecision;              /* Data Precision (not used) */
  140. int GlobalHeight;               /* Dimensions of overall image */
  141. int GlobalWidth;
  142. int ResyncInterval;             /* Resync interval (0 disables) */
  143. int GlobalNumberComponents;     /* Global number of components */
  144. int cn[MAXIMUM_COMPONENTS];     /* Translation index used */
  145. int hf[MAXIMUM_COMPONENTS];     /* Horizontal frequency */
  146. int vf[MAXIMUM_COMPONENTS];     /* Vertical frequency */
  147. int tq[MAXIMUM_COMPONENTS];     /* Quantization table used by */
  148. int Width[MAXIMUM_COMPONENTS];  /* Dimensions of component files */
  149. int Height[MAXIMUM_COMPONENTS];
  150. int BufferSize;                 /* Buffer sizes used */
  151. int Maxv, Maxh;                 /* Max Sampling Freq */
  152. int MDUWide, MDUHigh;           /* Number MDU wide */
  153. IMAGE *Image;
  154. };
  155.  
  156. SCAN {
  157. int NumberComponents;               /* Number of components in scan */
  158. int SSS;                            /* Spectral Selection Start (not used) */
  159. int SSE;                            /* Spectral Selection End (not used) */
  160. int SAH;                            /* Spectral approximation (not used) */
  161. int SAL;                            /* Spectral approximation (not used) */
  162. int *LastDC[MAXIMUM_SOURCES];       /* LastDC DPCM predictor */
  163. int *ACFrequency[MAXIMUM_SOURCES];  /* Frequency charts for custom huffman */
  164. int *DCFrequency[MAXIMUM_SOURCES];  /* table building */
  165. int LosslessBuffer[MAXIMUM_SOURCES][LOSSLESSBUFFERSIZE];
  166. int MDUWide, MDUHigh;
  167.                                     /* a integer buffer for lossless coding */
  168. IOBUF *Iob[MAXIMUM_SOURCES];        /* IOB per scan index  */
  169. int ci[MAXIMUM_SOURCES];            /* Index */
  170. int ta[MAXIMUM_SOURCES];            /* AC Tables for that scan index */
  171. int td[MAXIMUM_SOURCES];            /* DC Tables for scan index */
  172. int NumberACTablesSend;             /* Number of tables to send */
  173. int NumberDCTablesSend;
  174. int NumberQTablesSend;
  175. int sa[MAXIMUM_SOURCES];            /* AC table indices to send */
  176. int sd[MAXIMUM_SOURCES];            /* DC table indices to send */
  177. int sq[MAXIMUM_SOURCES];            /* Quantization table indices to send */
  178. };
  179.  
  180. #endif
  181.